<?php

class Home_model extends MY_CI_Model
{
    /**
     * @access public
     */
    public function __construct()
    {
        parent::__construct();

    }
    //获取今天的快递订单、洗车、订餐总数
    function get_order_count(){
        $date = date("Y-m-d", time());
        //快递
        $this->db->from('order_express');
		$this->db->where('hospital_id', $this->session->userdata('hospital_id'));
        $this->db->where('addtime >= ' . strtotime($date));
        $this->db->where('addtime <= ' . strtotime($date . " 23:59:59"));        
		$express_count =  (int)$this->db->count_all_results();
        //订餐
        $this->db->from('order_canteen');
		$this->db->where('hospital_id', $this->session->userdata('hospital_id'));
        $this->db->where('addtime >= ' . strtotime($date));
        $this->db->where('addtime <= ' . strtotime($date . " 23:59:59"));        
		$canteen_count =  (int)$this->db->count_all_results();
        //洗车
        $this->db->from('order_washing');
		$this->db->where('hospital_id', $this->session->userdata('hospital_id'));
        $this->db->where('addtime >= ' . strtotime($date));
        $this->db->where('addtime <= ' . strtotime($date . " 23:59:59"));        
		$washing_count =  (int)$this->db->count_all_results();
        return array($express_count, $canteen_count, $washing_count);
    }
    //获取小屋人员列表
    function get_helper_list(){
        $this->db->select('id, helper_sn, real_name, mobile, active');
        $this->db->from('helper');
		$this->db->where('hospital_id', $this->session->userdata('hospital_id'));  
        $this->db->where('is_delete', 0);      
        $this->db->where('helper_type', 1);  
		$item_list = $this->db->get()->result_array();
        return $item_list;
    }
    
    
    //获取新闻总数
    function get_news_count(){
        $this->db->from('hospital_news');
		$this->db->where('hospital_id', $this->session->userdata('hospital_id'));     
        $this->db->where('is_delete', 0);   
		return  (int)$this->db->count_all_results();
    }
}

?>